//
//  DetailItemView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 22.03.25.
//

import SwiftUI

struct DetailRowView: View {
    @Binding var item: AccountingDetailCombine
    
    var body: some View {
        HStack {
            CategoryIconView(item: item.category)
            VStack(alignment: .leading) {
                Text(item.getTitle())
                    .font(.system(size: 15))
                    .fontWeight(.medium)
                    .foregroundColor(Color.koiColorTitle)
                let subTitle = item.getSubTitle()
                if (!subTitle.isEmpty) {
                    Text(item.getSubTitle())
                        .font(.system(size:12))
                        .fontWeight(.medium)
                        .foregroundColor(Color.koiColorTitleSecond)
                }
            }
            .padding(.leading, 10)
            Spacer()
            Text(item.getAmount())
                .font(.system(size: 18))
                .fontWeight(.medium)
                .foregroundColor(Color.koiColorTitle)
        }
        .padding(10)
    }
}

@available(iOS 18.0, *)
#Preview {
    @Previewable @State var item = AccountingDetailCombine.previewData()
    DetailRowView(item: $item)
}
